Strict

Import agfx

Global myTmpScreen:TTmpScreen

Class TAgfx_test_app Extends TFramework


	Method OnCreate:Int()
		
		Super.OnCreate()
				
		myTmpScreen = New TTmpScreen		
		myTmpScreen.Prepare()
		
		DEBUG = True

	
		Return 0
	End
	
End


Class TTmpScreen Extends TScreen

	Field player:TPivot
	Field oBOX:TPivot
		
	' START when app is created
	Method Start:Void()

		Self.player = New TPivot("PLAYER",320,240,32,32)	
		Self.player.collision_type = COLLISION_TYPE_CIRCLE

		Self.oBOX = New TPivot("BOX",200,240,128,128)
		'Self.oBOX.collision_type = COLLISION_TYPE_BOX
		Self.oBOX.collision_type = COLLISION_TYPE_BOX
		

	End
	
	' main app logic loop update
	Method Update:Void()
		
		Self.player.SaveCurrentPosition()
		

		If KeyDown(KEY_LEFT) Then 
			Self.player.rotation -= 2.0*AppSpeed()
			Self.player.SetDirectionByRotation() 
		EndIf

		If KeyDown(KEY_RIGHT) Then 
			Self.player.rotation += 2.0*AppSpeed()
			Self.player.SetDirectionByRotation() 
		EndIf

		If KeyDown(KEY_UP) Then Self.player.MoveForward()

		Self.player.HandleCollisionWith(Self.oBOX)
		Self.player.Update()
		Self.oBOX.Update()
	End
	
	' main app render loop
	Method Render:Void()
		Cls
		Self.player.Draw()
		Self.oBOX.Draw()
	End
End
